<?php
declare (strict_types=1);

namespace app\controller\admin;

use app\BaseController;
use app\service\AdminService;
use app\service\SysUserService;
use app\service\UserService;
use think\annotation\route\Group;
use think\annotation\Route;

/**
 * 登陆
 * Class Login
 * @package app\controller\admin
 * @Group("admin/login")
 */
class Login extends BaseController
{
    /**
     * 登录
     * @Route("index", method="POST")
     */
    public function index()
    {
        //接收数据
        $data = [
            'account' => input('account', '', 'trim'),
            'password' => input('password', '', 'trim'),
        ];
        if (empty($data['account'])) {
            return json_error(12007);
        }
        if (empty($data['password'])) {
            return json_error(12008);
        }
        // 登录验证并获取包含访问令牌的用户
        $result = UserService::login($data['account'], $data['password']);
        return json_ok($result, 200);
    }


}
